Imports System.Data.OleDb
Imports System.Data.OracleClient

Public Class myDBConn

    Public Function myOleDbTable(ByVal SQL As String) As DataTable
        Dim cn As OleDbConnection
        Dim dsTemp As DataSet
        Dim dsCmd As OleDbDataAdapter
        Dim ConnStr As String


        ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db\ccapps.mdb"

        cn = New OleDbConnection(ConnStr)

        dsCmd = New OleDbDataAdapter(SQL, cn)
        dsTemp = New DataSet()
        dsCmd.Fill(dsTemp, "Query")
        Return dsTemp.Tables(0)
        dsTemp.Dispose()
    End Function


    Public Function myORATable(ByVal SQL As String) As DataTable
        Dim cn As OracleConnection
        Dim dsTemp As DataSet
        Dim dsCmd As OracleDataAdapter
        Dim ConnStr As String


        ConnStr = "DATA SOURCE=BSPT2;USER ID=SYSADM;PASSWORD=SYSADM;"

        cn = New OracleConnection(ConnStr)

        dsCmd = New OracleDataAdapter(SQL, cn)
        dsTemp = New DataSet()
        dsCmd.Fill(dsTemp, "Query")
        Return dsTemp.Tables(0)
        dsTemp.Dispose()
    End Function





    Public Function ORAExecute(ByVal SQL As String) As Long

        Dim ConnStr As String
        ConnStr = "DATA SOURCE=BSPT2;USER ID=SYSADM;PASSWORD=SYSADM;"

        Dim cn As New OracleConnection(ConnStr)
        Dim objCmd As New OracleCommand(SQL, cn)
        Dim lngResult As Long = 0

        objCmd.Connection.Open()
        lngResult = objCmd.ExecuteNonQuery
        cn.BeginTransaction.Commit()
        cn.Close()
        Return lngResult
    End Function

    Public Function ORAExecuteProc(ByVal prm_in As String, ByVal proc_name As String, ByVal prm_in_name As String, ByVal prm_out_name As String)

        Dim ConnStr As String
        ConnStr = "DATA SOURCE=BSPT2;USER ID=SYSADM;PASSWORD=SYSADM;"
        Dim cn As New OracleConnection(ConnStr)


        Dim myCmd As OracleCommand = New OracleCommand(proc_name, cn)
        myCmd.CommandType = CommandType.StoredProcedure
        myCmd.Parameters.Add(New OracleParameter(prm_in_name, OracleType.VarChar, 2))
        myCmd.Parameters(prm_in_name).Value = prm_in
        myCmd.Parameters(prm_in_name).Direction = ParameterDirection.Input

        myCmd.Parameters.Add(prm_out_name, OracleType.Number)
        myCmd.Parameters(prm_out_name).Direction = ParameterDirection.Output

        cn.Open()

        myCmd.ExecuteNonQuery()


    End Function
    Public Function Execute(ByVal SQL As String) As Long

        Dim ConnStr As String

        ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db\ccapps.mdb"

        Dim cn As New OleDbConnection(ConnStr)

        Dim objCmd As New OleDbCommand(SQL, cn)

        Dim lngResult As Long = 0

        objCmd.Connection.Open()

        lngResult = objCmd.ExecuteNonQuery

        cn.Close()

        Return lngResult

    End Function


End Class
